/**
 * @file contract.c
 *  @brief a tool for performing repeated edge contractions on a
 *         graph
 *  @author Matthias Stallmann
 *  @date 1992
 *  $Id: contract.c 10 2007-06-28 20:08:57Z mfms $
 */

/*
 *  Copyright (C) 1992 Matthias Stallmann.
 *  Contact: matt_stallmann@ncsu.edu
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program (file COPYING.txt); if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 *  USA.
 */

#include "Gdr.h"

 /* declarations and macros for the animation */
#define MSG_SIZE 100            /* maximum length of a message */
char msg[MSG_SIZE];
TWIN pwin;                      /* window for user prompts */
#define XW 1                    /* prompt window coordinates */
#define YW 1
#define init_prompt_window (pwin = create_text_window(XW,YW,""))
#define destroy_prompt_window (kill_window(pwin))
#define wait(msg) (write_text_window(pwin,msg),suspend_animation(),\
				   hide_window(pwin))
#define COUNT 4

void animat(void)
{
  vertex u,v,w;
  edge e;

  init_prompt_window;
	
  while (TRUE) {
	wait("Do other operations");
	write_text_window(pwin,
			  "Select 2 vertices for contraction\n or type 'q' to quit");
	if ((u = select_vertex()) == NULL_VERTEX) break;
	highlight_vertex(u);
	if ((v = select_vertex()) == NULL_VERTEX) break;
	highlight_vertex(v);
	blink_vertex(u,COUNT);
	for_adjacent(u,e,w) {
	  if (w != v) add_edge(v,w,edge_label(e));
	}
	delete_vertex(u);
	un_highlight_vertex(v);
  }
  destroy_prompt_window;
}

/*  [Last modified: 2007 06 28 at 19:42:53 GMT] */
